from conf import apikey
from openai import OpenAI
#application-e7a851e2bb1f41115cad20b80fb318bf
#http://10.110.70.30:8080/
def get_gpt_client():
    url = "https://api.xi-ai.cn/v1"
    client = OpenAI(
        api_key= apikey,
        base_url=url,
    )
    return client

def chat(client,messages,model="gpt-4o-mini"):
    completion = client.chat.completions.create(
      model=model,
      messages=messages,

    )
    return completion.choices[0].message.content

gpt = get_gpt_client()
print(chat(gpt, [{"role": "user", "content": 'KFC是什么'}],'gpt-4o-mini'))